<?php

namespace Xrfg\Api\Trading\Spot\Resources;

use App\Http\Resources\Resource;
use Illuminate\Support\Facades\Auth;
use Xrfg\Core\Trading\Spot\Models\Trade;

class TradeResource extends Resource
{
    public function toArray($request)
    {
        /* @var Trade $this */
        return [
            'id' => $this->id,
            'symbol' => $this->symbol,
            'side' => $this->side,
            'price' => $this->price,
            'fee' => Auth::id() === $this->buy_user_id ? $this->buy_fee : $this->sell_fee,
            'created_at' => $this->created_at,
        ];
    }
}
